package com.yuejian_06.yuejian_06.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.squareup.picasso.Picasso;
import com.yuejian_06.yuejian_06.Listener.MeListener;
import com.yuejian_06.yuejian_06.R;
import com.yuejian_06.yuejian_06.activity.FollowListActivity;
import com.yuejian_06.yuejian_06.activity.PostInfoActivity;
import com.yuejian_06.yuejian_06.activity.SetpersonalActivity;
import com.yuejian_06.yuejian_06.activity.UpdateActivity;
import com.yuejian_06.yuejian_06.bean.ClubBean;
import com.yuejian_06.yuejian_06.bean.FollowListBean;
import com.yuejian_06.yuejian_06.bean.PostListBean;
import com.yuejian_06.yuejian_06.bean.UserUpdateBean;
import com.yuejian_06.yuejian_06.model.MeModel;

import java.util.List;

import static com.yuejian_06.yuejian_06.R.id.follow_img;

/**
 * Created by __ZL__ on 2017/10/10.
 */

public class FollowAdapter  extends RecyclerView.Adapter<RecyclerView.ViewHolder>{
    private Context mContext;
    private List mDataList;
    private LayoutInflater mLayoutInflater;
    public FollowAdapter(Context mContext, List mDataList) {
        this.mContext = mContext;
        this.mDataList = mDataList;
        mLayoutInflater = LayoutInflater.from(mContext);
    }
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v =mLayoutInflater.from(parent.getContext()).inflate(R.layout.flcardview,parent,false);
        return new FollowAdapter.ViewHolder(v);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder,int position) {
        final FollowListBean entity =(FollowListBean) mDataList.get(position);
        if (null == entity)
            return;
        FollowAdapter.ViewHolder viewHolder = (FollowAdapter.ViewHolder) holder;
        viewHolder.club_name.setText(entity.getClub_name());
        //String p = String.valueOf(entity.getPrice());
        if (!"".equals(entity.getClub_pic()))
            Picasso.with(mContext).load("http://10.0.2.2/yuejian/Public/clubpics/"+entity.getClub_pic()).into(viewHolder.club_pic);
        viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(mContext,FollowListActivity.class);
                intent.putExtra("follow_id",entity.getFollow_id()+"");
                mContext.startActivity(intent);
            }
        });
    }

    @Override
    public int getItemCount() {
        return mDataList.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder{
        private TextView club_name;
        private ImageView club_pic,follow_img;
        public ViewHolder(View itemView) {
            super(itemView);
            club_name = (TextView) itemView.findViewById(R.id.club_name);
            club_pic = (ImageView) itemView.findViewById(R.id.club_pic);
            follow_img = (ImageView) itemView.findViewById(R.id.follow_img);
        }
    }

}